package marchsoft.modules.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import lombok.RequiredArgsConstructor;
import marchsoft.modules.system.entity.SysRelationFile;
import marchsoft.modules.system.mapper.SysRelationFileMapper;
import marchsoft.modules.system.service.ISysRelationFileService;
import marchsoft.base.BasicServiceImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
* <p>
* 附件关系表 服务实现类
* </p>
*
* @author hxw
* @since 2024-09-30
*/
@Service
public class SysRelationFileServiceImpl extends BasicServiceImpl<SysRelationFileMapper, SysRelationFile> implements ISysRelationFileService {

    @Autowired
    private  SysRelationFileMapper sysRelationFileMapper;

    @Autowired
    private  ISysRelationFileService sysRelationFileService;
    @Override
    public void deleteFile(List<Long> ids, String serviceType) {
        UpdateWrapper<SysRelationFile>uw = new UpdateWrapper<>();
        uw.in("service_id", ids)
                .eq("service_type",serviceType)
                .set("status","0");
        sysRelationFileService.update(uw);
    }

    @Override
    public void saveFile(Long fileId, Long serviceId,String serviceType) {
        SysRelationFile file = sysRelationFileService.getById(fileId);
        file.setServiceId(serviceId);
        file.setServiceType(serviceType);
        sysRelationFileService.updateById(file);
    }


}

